package com.situ.mall.admin.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.mall.admin.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lwj
 * @since 2023-09-08
 */
public interface UserMapper extends BaseMapper<User> {


    List<User> list(@Param("username") String username, @Param("name") String name, @Param("status") String status);

    @Insert("insert into user( username, password, name, create_time,avatar) values (#{username},#{password},#{name},#{createTime},#{avatar})")
    int insert(User u);

    //@Update("update user set username = #{username},name = #{name} where id = #{id}")
    void update(User u);

    @Update("update user set status = '-1' where id = #{id}")
    void delete(Integer id);

    //编辑返回的值
    @Select("select * from user where id = #{id} and status in ('0','1') ")
    User edit(Integer id);
    @Select("select * from user where username = #{username} and status in ('0','1') ")
    User selectByUserName(String username);

    @Select("select username from user where id = #{id} and status in ('0','1') ")
    String selectById(Integer id);

    int delete2(String[] ids);

    @Update("update user set password = #{password1} where id = #{id}")
    void resetPassword(String password1, Integer id);
}
